import * as Cesium from '@cesiumjs';
import {
  G3xObjBase
} from "@g3xbase"
import * as g3xUtils from "@g3x/utils";
import * as g3vUtils from "@g3v/utils";

/**
 * 地形等高线
 * @extends XbsjBase
 */

class Contour extends G3xObjBase {

  constructor(ramp) {

    super(ramp);
    var _this = this;
    _this.ramp = ramp;
  }
}

g3xUtils.g3x_defineClassProperties(Contour, [{
  key: '_apply',
  value: function _apply() {
    if (!this.enabled) return;
    //获取当前globe设置的材质，如果材质上没有
    var material = this._ramp._globe.material;
    if (!material) return;
    var uniforms = void 0;
    if (material.type == 'ElevationContour') {
      uniforms = material.uniforms;
    } else if (material.materials && material.materials.contour) {
      uniforms = material.materials.contour.uniforms;
    }

    //宽度和间隔
    uniforms.width = this.width;
    uniforms.spacing = this.spacing;
    //设置颜色
    uniforms.color.red = this.color[0];
    uniforms.color.green = this.color[1];
    uniforms.color.blue = this.color[2];
    uniforms.color.alpha = this.color[3];
  }
}]);


Contour.defaultOptions = {
  /**
   * 开启等高线
   * @type {boolean}
   * @default false
   * @instance
   * @memberof Contour
   */
  enabled: false,
  /**
   * 等高线宽度
   * @type {number}
   * @default 1
   * @instance
   * @memberof Contour
   */
  width: 1,
  /**
   * 等高线间隔
   * @type {number}
   * @default 100
   * @instance
   * @memberof Contour
   */
  spacing: 100,
  /**
   * 等高线颜色
   * @type {number[]}
   * @default [1,0,0,1]
   * @instance
   * @memberof Contour
   */
  color: [1, 0, 0, 1]
};

export default Contour;
export {
  Contour
};
